# test-script for QUTest unit testing harness
# see https://www.state-machine.com/qtools/qutest.html

def on_reset():
    expect_pause()
    glb_filter(GRP_ALL)
    continue_test()
    expect("@timestamp TE0-Arm  Obj=l_blinky.timeEvt,AO=l_blinky,*")
    expect("===RTC===> St-Init  Obj=l_blinky,State=QHsm_top->Blinky_off")
    expect("@timestamp LED 0")
    expect("===RTC===> St-Entry Obj=l_blinky,State=Blinky_off")
    expect("@timestamp Init===> Obj=l_blinky,State=Blinky_off")
    expect_run()
    current_obj(OBJ_SM_AO,"l_blinky")
    current_obj(OBJ_TE,"l_blinky.timeEvt")


test("TIMEOUT_SIG->l_blinky")
query_curr(OBJ_SM)
expect("@timestamp Query-SM Obj=l_blinky,State=Blinky_off")
query_curr(OBJ_AO)
expect("@timestamp Query-AO Obj=l_blinky,State=Blinky_off")
query_curr(OBJ_TE)
expect("@timestamp Query-TE Obj=l_blinky.timeEvt,Rate=0,Sig=TIMEOUT_SIG,*")
current_obj(OBJ_MP,"EvtPool1")
query_curr(OBJ_MP)
expect("@timestamp Query-MP Obj=EvtPool1,*")
post("TIMEOUT_SIG")
expect("@timestamp MP-Get   Obj=EvtPool1,*")
expect("@timestamp QF-New   Sig=TIMEOUT_SIG,*")
expect("@timestamp AO-Post  Sdr=QS_RX,Obj=l_blinky,Evt<Sig=TIMEOUT_SIG,*")
expect("@timestamp AO-GetL  Obj=l_blinky,Evt<Sig=TIMEOUT_SIG,*")
expect("@timestamp Disp===> Obj=l_blinky,Sig=TIMEOUT_SIG,State=Blinky_off")
expect("@timestamp LED 1")
expect("===RTC===> St-Entry Obj=l_blinky,State=Blinky_on")
expect("@timestamp ===>Tran Obj=l_blinky,Sig=TIMEOUT_SIG,State=Blinky_off->Blinky_on")
expect("@timestamp QF-gc    Evt<Sig=TIMEOUT_SIG,*")
expect("@timestamp MP-Put   Obj=EvtPool1,*")
expect("@timestamp Trg-Done QS_RX_EVENT")

test("timeEvt->Blinky_off (tick)")
current_obj(OBJ_TE,"l_blinky.timeEvt")
tick()
expect("           Tick<0>  Ctr=*")
expect("@timestamp TE0-Post Obj=l_blinky.timeEvt,Sig=TIMEOUT_SIG,AO=l_blinky")
expect("@timestamp AO-Post  Sdr=QS_RX,Obj=l_blinky,Evt<Sig=TIMEOUT_SIG,*")
expect("@timestamp AO-GetL  Obj=l_blinky,Evt<Sig=TIMEOUT_SIG,*")
expect("@timestamp Disp===> Obj=l_blinky,Sig=TIMEOUT_SIG,State=Blinky_off")
expect("@timestamp LED 1")
expect("===RTC===> St-Entry Obj=l_blinky,State=Blinky_on")
expect("@timestamp ===>Tran Obj=l_blinky,Sig=TIMEOUT_SIG,State=Blinky_off->Blinky_on")
expect("@timestamp Trg-Done QS_RX_TICK")

test("timeEvt->Blinky_on (tick)", NORESET)
tick()
expect("           Tick<0>  Ctr=*")
expect("@timestamp TE0-Post Obj=l_blinky.timeEvt,Sig=TIMEOUT_SIG,AO=l_blinky")
expect("@timestamp AO-Post  Sdr=QS_RX,Obj=l_blinky,Evt<Sig=TIMEOUT_SIG,*")
expect("@timestamp AO-GetL  Obj=l_blinky,Evt<Sig=TIMEOUT_SIG,*")
expect("@timestamp Disp===> Obj=l_blinky,Sig=TIMEOUT_SIG,State=Blinky_on")
expect("@timestamp LED 0")
expect("===RTC===> St-Entry Obj=l_blinky,State=Blinky_off")
expect("@timestamp ===>Tran Obj=l_blinky,Sig=TIMEOUT_SIG,State=Blinky_on->Blinky_off")
expect("@timestamp Trg-Done QS_RX_TICK")
